package com.maimao.info.client.factory;

import com.maimao.core.enums.RespCode;
import com.maimao.core.model.resp.Result;
import com.maimao.info.client.GoodsClient;
import com.maimao.model.info.Collect;
import com.maimao.model.info.vo.FollowGoods;
import com.maimao.model.user.Foot;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author MaoLin Wang
 * @date 2020/11/30 10:03 下午
 */
@Component
@Slf4j
public class GoodsFallBackFactory implements FallbackFactory<GoodsClient> {

    @Override
    public GoodsClient create(Throwable cause) {
        String errorMsg = cause.getMessage() == null ? "" : cause.getMessage();

        return new GoodsClient() {
            @Override
            public Result<List<FollowGoods>> followGoods(List<Collect> collectList) {
                log.error("调用[GoodsClient-followGoods({})]出错 :{}", collectList, errorMsg);
                return Result.fail(RespCode.FAIL, "查询用户关注商品出错");
            }


        };
    }
}
